package cli

import (
	"github.com/ihaiker/tfwrapper/internal/orch"
	"github.com/ihaiker/tfwrapper/internal/parser"
	"github.com/ihaiker/tfwrapper/internal/util"
	"github.com/urfave/cli/v2"
)

var validate = &cli.Command{
	Name: "validate", Usage: "validate tfwrapper configuration",
	UsageText: "validate tfwrapper configuration",
	Action: showHelp(func(ctx *cli.Context) error {
		wrapper, err := parser.Parser(ctx.App.Version, *flags)
		if util.HasErrors(err) {
			return err
		}
		_, err = orch.Validate(wrapper)
		return err
	}),
}

func init() {
	app.Commands = append(app.Commands, validate)
}
